<?php
/**
 * Created by PhpStorm.
 * User: yiyu
 * Email: smalleasyu@gmail.com
 * Date: 2020-01-31 22:26:05
 * Desc:
 */

namespace app\api\controller\wx;

use app\core\exception\{BusinessException, ErrorCode};
use app\base\service\Pay\WxPayService;
use app\core\log\Log4dd;
use think\Request;

class WxPayNotifyController
{

    /**
     * Desc: 处理微信支付回调
     * Date: 2020/2/1 11:30
     * Author: yiyu
     * @return mixed
     */
    public function miniOrderHandler()
    {
        Log4dd::info('微信支付原始回调数据', ['data' => Request::instance()->param()]);
        $app_id = input('app_id/s', 'wx5a158ad716b5e959');

        if (empty($app_id)) {
            throw new BusinessException(ErrorCode::COMMON_SYSTEM_ERROR, 'notify_url缺少app_id');
        }

        return WxPayService::instance()->checkOrderNotify($app_id);

    }
}